// ==================================================================================
// Shared Genomics Project MPI Codebase
// Version 1.0 30/04/2010
//
// (c) 2010 University of Manchester all rights reserved
//
// This file is distributed under the GNU General Public License, Version 2.  
// Please see the file COPYING.txt for more details
// ==================================================================================

#ifndef _SEEDFILE_H_
#define _SEEDFILE_H_

#include "options.h"

#ifdef __cplusplus
extern "C" {
#endif

/*!
\file
\ingroup	gio
\brief		Random Seed File
\details
	Header provides methods to create an array of random seeds to initialise the RNG for each core of the NIBHI cluster.<br>
	Random values taken from the Mersenne Twister initialised with the current system clock.<br>
	Each seed value is a taken from 0 to current system clock in milleseconds.<br>
	Each core in the NIBHI cluster is given a unique seed value.<br>
	A seed file typically uses the suffix \ref SUFFIX_RSEED_FILE .
*/

/*! 
\brief Load a seed array from file.
\details
	The input file path is a concatonation of \ref selected_options::rdir, \ref selected_options::szRunId
	and \ref SUFFIX_RSEED_FILE .
\param [in] ops Input file location
\param [in,out] nSeeds Pointer to store the size of the seed array
\return integer array of random seeds or NULL on failure
*/
int* seedfile_load(struct selected_options *ops, int *nSeeds);

/*! 
\brief Write a seed array to file.
\details
	The output file path is bound to \ref selected_options::szSeedFileName.<br>
	Make sure that the local RNG is initialised by calling \ref init_genrand().
\param [in] ops Output file location
\param [in] numprocs Size of seed array to create
\return 1 on success, 0 on failure
\sa init_genrand()
*/
int seedfile_create(struct selected_options *ops, int numprocs);

int seedfile_create_and_copy(struct selected_options *ops, int numprocs, int rank);

int rseed_log(struct selected_options *ops, unsigned long seed);

#ifdef __cplusplus
}
#endif

#endif // _SEEDFILE_H_
